{strip}

{literal}
<script>

$(document).ready(function() { 
	var options = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
    }; 
 
    // bind to the form's submit event 
    $('#service_add_form').submit(function() { 
    	//fakeSubmit.UpdateEditorFormValue();
        $(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        //checkForm();
        return false;
    });
    
    $('#file_upload').uploadify({
          'uploader'  : '/public/scripts/uploadify.swf',
          'script'    : '/upload',
          'cancelImg' : '/public/scripts/cancel.png',
          'auto'      : false,
          'method'	  : 'post',
          'multi'	:	false,
          'onComplete'  : function(event, ID, fileObj, response, data) {
          		
          		var obj = jQuery.parseJSON(response);
          		$('#filesId').val(obj.filesId);
          		$("#uploadBox").html('<img src="/minigen.php?filepath='+obj.path+'&filename='+obj.name+'&width=80&height=80&ext='+obj.ext+'" alt="laptop"/>');
          		//alert($('#filesId').val());
			},
			'onError'     : function (event,ID,fileObj,errorObj) {
			      alert(errorObj.type + ' Error: ' + errorObj.info);
			},
			'scriptData'  : {{/literal}'fileTypesId':'{$fileTypesId}', 'sessionId': '{$sessionId}','destination': '{$uploadDestination}'{literal}}
		
        });
});

// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    var queryString = $.param(formData); 
    //return checkForm(); 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
	//scroll(0,0);
	//showPopup2(responseText, 'New default matrix', false);
	window.location.reload();
}
</script>
{/literal}

<div id="backoffice" >
<table align="center"><tr><td>
<form id="service_add_form" method="POST" action="/shipping-services/save" onsubmit="">

<fieldset>
<legend>Fill the form</legend>

	<div id="uploadBox"></div>
	<div id="uploadComponent" style="padding: 10px;">
		<input id="file_upload" name="file_upload" type="file" />
		<a href="javascript:$('#file_upload').uploadifyUpload();">Upload File</a>
	</div>
	<div>
		<label for="f4">Shipping Service</label>
		<input type="text" name="addForm[service]" value="" />
		<input type="hidden" name="addForm[shippingServicesId]" value="0" />
		<input type="hidden" id="filesId" name="addForm[filesId]" value="0" />
	</div>
	<div>
		<label>Shipping Price</label>
		<input type="text" name="addForm[price]" value="" />
	</div>	
	<div>
		<label for="f3">Description</label>
		<textarea rows="3" name="addForm[description]" style="width: 60%"></textarea>		
	</div>
	
	<div class="v_spacer"> </div>
	<div>
		<div class="left">
			<input type="button" value="Resign" class="submit" onclick="closePopup();"/>
		</div>
		<div class="right">
			<input type="submit" value="Submit" class="submit"/>
		</div>
	</div>

	
</fieldset>
</form>
</td></tr></table>
</div>
{/strip}